﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Manage_news_InfoList : System.Web.UI.Page
{
    private int COUNT;

    public BLL.Information info;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            initData();
        }
    }
    public void initData()
    { 
        info= new BLL.Information();
        DataView dv = info.FindAll(Convert.ToInt32(J.Comm.Url.Output(Request["nKey"]))).Tables[0].DefaultView;

        COUNT = dv.Table.Rows.Count;
        AspNetPager1.RecordCount = COUNT;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = dv;
        pds.AllowPaging = true;
        pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
        pds.PageSize = AspNetPager1.PageSize;
        Repeater1.DataSource = pds;
        Repeater1.DataBind();
        if (pds.Count >0)
        {
            AspNetPager1.Visible = true;
        }
        else
        {
            AspNetPager1.Visible = false;
        }
    }
    protected int PageCount
    {
        get { return COUNT; }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        initData();
    }
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            info = new BLL.Information();
            BLL.Model.MInformation minfo=new BLL.Model.MInformation();
            minfo.ID=e.CommandArgument.ToString();
            minfo.WorkType = (int)BLL.WorkType.Remove;
            info.DoWork(minfo);

            J.Comm.Url.ShowStartup(this.Page,"删除成功！");
            initData();
        }
    }
}
